<?php

class loginController{

    /*
    *用户登录
    **/
	public function login(){

	    include(ROOT.'view/admin/tpl/login.html');
    }

    public function loginAction(){
        $tno=$_POST['tno'];
        $pwd=trim($_POST['pwd']);

        $model=new UserModel();

        $row=$model->checkUser($tno,$pwd);
        //var_dump($row);
        $message = new MessageTool();
        if(empty($row)){
            echo 1;
            exit;
        }else{
            $_SESSION['uname']=$row['uname'];
            $_SESSION['user_id']=$row['uid'];
            $data['logip'] = $_SERVER["REMOTE_ADDR"];
            $_SESSION['time'] = date("Y-m-d H:i:s",$row['logtime']);
            $_SESSION['ip']=$data['logip'];
            $_SESSION['lip']=$row['logip'];
            $data = $model->fillFields($data);
            if($model->update($data,$row['uid'])){
                echo 2;
                exit;
            }else{
                echo 3;
                exit;
            }

        }
    }
}
?>